Maximum Width of Binary Tree
Easy
Question
Given the root of a tree, return the maximum width of the tree.
Input: root = [1, 2, 3, None, None, 6]
Output: 2
If the root is at the 0th level, the maximum width of the tree is at the 1st level with 2 nodes.
Input: root = [1, 2, 3, 4, 5, None, None, 8]
Output: 2
If the root is at the 0th level, the tree has a maximum width of 2 nodes on the 1st or 2nd levels.
Clarify the problem
What are some questions you'd ask an interviewer?
Understand the problem
What is the maximum width of this tree? root = [1, 2, 3, 4, 5, 6, 7, 8]
1
2
3
4
Take a moment to understand the problem and think of your approach before you start coding.